package cn.hx.mall.goods.service.impl;

import cn.hx.mall.goods.dao.ProductFullReductionDao;
import cn.hx.mall.goods.entity.ProductFullReduction;
import cn.hx.mall.goods.service.ProductFullReductionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品满减表(只针对同商品)(ProductFullReduction)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 15:58:13
 */
@Service("productFullReductionService")
public class ProductFullReductionServiceImpl implements ProductFullReductionService {
    @Resource
    private ProductFullReductionDao productFullReductionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ProductFullReduction queryById(Long id) {
        return this.productFullReductionDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ProductFullReduction> queryAllByLimit(int offset, int limit) {
        return this.productFullReductionDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param productFullReduction 实例对象
     * @return 实例对象
     */
    @Override
    public ProductFullReduction insert(ProductFullReduction productFullReduction) {
        this.productFullReductionDao.insert(productFullReduction);
        return productFullReduction;
    }

    /**
     * 修改数据
     *
     * @param productFullReduction 实例对象
     * @return 实例对象
     */
    @Override
    public ProductFullReduction update(ProductFullReduction productFullReduction) {
        this.productFullReductionDao.update(productFullReduction);
        return this.queryById(productFullReduction.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.productFullReductionDao.deleteById(id) > 0;
    }
}